package djboom.materials.display.elements {
	import flash.events.Event;
	import flash.geom.Point;

	import org.casalib.util.DrawUtil;

	import flash.geom.Matrix;
	import flash.display.GradientType;

	import org.casalib.display.CasaShape;

	/**
	 * .
	 * <br>
	 * 
	 * @author DJ BooM 
	 * @since 22.04.2010
	 * 
	 */

	public class Diamond extends CasaShape {

		// ----------------------------------------------------------------------------
		// Константы класса.
		// ----------------------------------------------------------------------------

		public static const BLUE:uint = 0x076aa6;				public static const GRAY:uint = 0x919191;				public static const GREEN:uint = 0x798f00;		
		// ----------------------------------------------------------------------------
		// Свойства класса.
		// ----------------------------------------------------------------------------

		private var _gradientMatrix:Matrix = new Matrix();

		// ----------------------------------------------------------------------------
		// Конструктор.
		// ----------------------------------------------------------------------------

		public function Diamond(type:uint) {
			super();
			
			_gradientMatrix.createGradientBox(18, 16, -Math.PI / 2);
			
			graphics.lineStyle(2, type);
			
			switch(type) {
				case BLUE:
					graphics.beginGradientFill(GradientType.LINEAR, [0x0688b3, 0x23b7e8], [1, 1], [0, 255], _gradientMatrix);
					break;
				case GRAY:
					graphics.beginGradientFill(GradientType.LINEAR, [0xa0a0a0, 0xe0e0e0], [1, 1], [0, 255], _gradientMatrix);
					break;
				case GREEN:
					graphics.beginGradientFill(GradientType.LINEAR, [0x8ca311, 0xc8e42c], [1, 1], [0, 255], _gradientMatrix);
					break;
			}
			
			DrawUtil.drawShape(graphics, new Array(new Point(4, 0), new Point(14, 0), new Point(18, 8), new Point(14, 16), new Point(4, 16), new Point(0, 8)));
			graphics.endFill();
			
			addEventListener(Event.REMOVED_FROM_STAGE, clearContent);
		}	 

		private function clearContent(event:Event):void {
			_gradientMatrix = null;
			
			this.graphics.clear();
		}

		// ----------------------------------------------------------------------------
		// Методы класса.
		// ----------------------------------------------------------------------------

		// ----------------------------------------------------------------------------
		// Публичные методы.
		// ----------------------------------------------------------------------------
		
		// ----------------------------------------------------------------------------
        // Публичные свойства.
        // ----------------------------------------------------------------------------
	}
}
